package work.mediway.mdm.biz.bo;

import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.List;
import java.util.Map;
import java.util.Set;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import lombok.Data;

/**
 * 数据质量数据构造
 *
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2022/7/19
 */
@Data
public class DataQualityDataBO {

    /**
     * 默认的布隆过滤器大小，单位为MB（10MB约存85亿bit）
     */
    public static final int DEFAULT_FILTER_SIZE = 10;


    /**
     * 源系统数量
     */
    private Long sourceCount;

    /**
     * 目标系统数量
     */
    private Long targetCount;

    /**
     * 目标系统中缺失数据
     */
    private List<String> sourceNoExist;

    /**
     * 源系统缺失数据
     */
    private List<String> targetNoExist;

    /**
     * 小数据量表源端数据存储池
     */
    private Set<String> sourceData;

    /**
     * 小数据量表目标端数据存储池
     */
    private Set<String> targetData;


    /**
     * 源数据存储文件列表
     */
    private Map<Long, String> sourceFilePath;

    /**
     * 目标数据存储文件列表
     */
    private Map<Long, String> targetFilePath;

    /**
     * 源数据文件写入流
     */
    private Map<Long, FileOutputStream> sourceFileOutputStream;

    /**
     * 目标数据文件写入流
     */
    private Map<Long, FileOutputStream> targetFileOutputStream;


    private Map<Long, FileChannel> sourceFileChannel;

    private Map<Long, FileChannel> targetFileChannel;

    private Map<Long, ByteBuffer> sourceByteBuffer;

    private Map<Long, ByteBuffer> targetByteBuffer;

    /**
     * 数据拆分文件个数
     */
    private Long bucketNum;

    public DataQualityDataBO() {
        this.sourceData = CollUtil.newHashSet();
        this.targetData = CollUtil.newHashSet();
        this.sourceNoExist = CollUtil.newArrayList();
        this.targetNoExist = CollUtil.newArrayList();
        this.sourceCount = 0L;
        this.targetCount = 0L;
        sourceFilePath = MapUtil.newHashMap();
        targetFilePath = MapUtil.newHashMap();
        sourceFileOutputStream = MapUtil.newHashMap();
        targetFileOutputStream = MapUtil.newHashMap();
        sourceFileChannel = MapUtil.newHashMap();
        targetFileChannel = MapUtil.newHashMap();
        sourceByteBuffer = MapUtil.newHashMap();
        targetByteBuffer = MapUtil.newHashMap();
    }
}
